package com.home.school.config.app;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author: cuiyutian1
 * @date: 2021/12/4 22:50
 * @description:
 */
@Configuration
public class WebConfig implements WebMvcConfigurer {

    @Value("${web.upload.image}")
    private String imageUrl;

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
//        String projectDir = System.getProperty("user.dir");
//        // 日期文件夹
//        String nowFolder = new SimpleDateFormat("yyyyMMdd").format(new Date());
//        // 获取项目路径到webapp
//        String filepath = projectDir + imageUrl + "/" + nowFolder;
//
//        System.out.println(filepath);

        registry.addResourceHandler(imageUrl +"/**").addResourceLocations("file:E:\\waibao\\spring boot 服饰\\stu-attend\\image\\");
    }

}
